package main

import (
	"fmt"
	"io/ioutil"
	"strconv"
)

func main() {
	filePath := "C:\\Users\\mlamp\\temp\\go\\file\\write\\demo.txt"
	str := ""
	for i := 0; i < 5; i++ {
		str += "hello-" + strconv.Itoa(i) + "\n"
	}
	err := ioutil.WriteFile(filePath, []byte(str), 0777)
	if err != nil {
		fmt.Println("写入文件失败！", err)
	} else {
		fmt.Println("写入文件成功！")
	}
}
